package cn.hxzy.course.mapper;

import cn.hxzy.common.domain.Chapter;
import cn.hxzy.common.domain.Section;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
public interface ChapterMapper extends BaseMapper<Chapter> {


    /**
     * 根据章节ID修改某章节
     *
     * @param chapterId
     * @return
     */
    @Update("update sys_chapter set chapter_name=#{chapterName} where chapter_id=#{chapterId}")
    int updateChapter(Integer chapterId, String chapterName);

    /**
     * 根据章节名称查询章节
     */
    @Select("select * from sys_chapter where chapter_name=#{chapterName} and deleted=0 ")
    Chapter getChapterByName(String chapterName);



    @Select("select * from sys_chapter where course_id=#{courseId} and deleted=0 ")
    List<Chapter> getChapterById(Integer courseId);

}
